package com.tlias.service.impl;

import com.tlias.entity.EmpLog;
import com.tlias.mapper.EmpLogMapper;
import com.tlias.service.EmpLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service //@Service注解，@Component注解衍生注解,标注在标注在业务层类上,和@Component注解效果一模一样  表示这个类被Spring管理将这个类放到Spring容器中管理
public class EmpLogServiceImpl implements EmpLogService {
    @Autowired
    private EmpLogMapper empLogMapper;
    /*
    * 插入操作日志
    * @param EmpLog
    * */
//    @Transactional(propagation = Propagation.REQUIRED)//开启事务,默认事务传播属性为REQUIRED有则使用，无则创建
    @Transactional(propagation = Propagation.REQUIRES_NEW)//事务传播属性设置为REQUIRES_NEW,保证事务独立
    @Override
    public void insertLog(EmpLog empLog) {
        empLogMapper.insertLog(empLog);
    }
}
